'use strict';
app.service('programGoodsManageService',['$q','utilService',function($q,utilService){
    //��ѯ��Ʒ����������
    this.findModules = function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain +  'modules/all'
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("���ӷ���������");
        });
        return deferred.promise;
    }


    //���ģ������Ʒ
    this.addModulesGoods=function($scope){
        var deferred = $q.defer();
        utilService.api({
            url:$scope.app.domain+"modules/goods",
            data:$scope.modulesAddVO
        }).then(function(result){
            deferred.resolve(result);
        });
        return deferred.promise;
    }

    //��ѯ����������
    this.getShopList = function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain +  'shop/program',
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("���ӷ���������");
        });
        return deferred.promise;
    }

    //查询预约信息
    this.checkReserve = function($scope){
        var deferred = $q.defer();
        utilService.get({
            url:$scope.app.domain + 'goods/serve/id',
            params:{serveId:$scope.id}
        }).then(function(response){
            deferred.resolve(response.data);
        },function(e){
            console.error(e);
            deferred.reject("连接服务器出错！");
        });
        return deferred.promise;
    }
}]);